package com.lanou.projecta_163news.fragment;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.Toast;

import com.lanou.projecta_163news.base.BaseFragment;
import com.lanou.projecta_163news.fragment.mainAdapter.ReadRecyclerAdapter;
import com.lanou.projecta_163news.fragment.mainAdapter.ReadItemListener;
import com.lanou.projecta_163news.fragment.mainAdapter.Read;
import com.lanou.projecta_163news.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dllo on 16/3/7.
 */
public class ReadFragment extends BaseFragment implements ReadItemListener {
    private RecyclerView recyclerView;
    private ReadRecyclerAdapter readRecyclerAdapter;
    private List<Read> readData;


    @Override
    protected void initView() {
        recyclerView = bindView(R.id.fragment_read_rv);
    }

    @Override
    protected void initData() {
        ininRecyclerView();

    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_read;
    }

    @Override
    protected ViewGroup getNull() {
        return null;
    }

    private void ininRecyclerView() {
        readRecyclerAdapter = new ReadRecyclerAdapter();
        recyclerView.setAdapter(readRecyclerAdapter);
        GridLayoutManager gm = new GridLayoutManager(getContext(), 1);
        gm.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(gm);

        readData = new ArrayList<>();
        for (int i = 0; i < 1; i++) {
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
            readData.add(new Read(R.drawable.amata, "俄罗斯制主战坦克 140mm滑膛炮 20mm机关炮 13mm机枪", "T-14阿玛塔主战坦克"));
        }
        readRecyclerAdapter.addReData(readData);
        readRecyclerAdapter.setReRvItemListener(this);
    }

    @Override
    public void reRvItemListener(Read read) {
        Toast.makeText(getContext(), read.getContentTv().toString(), Toast.LENGTH_SHORT).show();
    }
}
